Resolve disagreements in accounting of tooltip positions on Android
authorPo Lu <luangruo@yahoo.com>
Sun, 7 Apr 2024 06:39:42 +0000 (14:39 +0800)
committerPo Lu <luangruo@yahoo.com>
Sun, 7 Apr 2024 06:51:29 +0000 (14:51 +0800)
* java/org/gnu/emacs/EmacsService.java (getLocationInWindow):
New function.

* java/org/gnu/emacs/EmacsWindow.java (translateCoordinates):
Derive "root window" position from the origin point of the
containing activity's window rather than that of the screen,
the two of which differ when "freeform mode" is enabled.

java/org/gnu/emacs/EmacsService.java
java/org/gnu/emacs/EmacsWindow.java

index 34682feeedb7ab86cc3644f7486f9829a17229e5..052793eabaf7aebedfad62e33d783d12db8cb74b 100644 (file)
@@ -387,6 +387,23 @@ public final class EmacsService extends Service
     EmacsService.<Void>syncRunnable (task);
   }
 
+  public void
+  getLocationInWindow (final EmacsView view, final int[] coordinates)
+  {
+    FutureTask<Void> task;
+
+    task = new FutureTask<Void> (new Callable<Void> () {
+       public Void
+       call ()
+       {
+         view.getLocationInWindow (coordinates);
+         return null;
+       }
+      });
+
+    EmacsService.<Void>syncRunnable (task);
+  }
+
 \f
 
   public static void
index 91e97fa8b61d426109cabc92ac645745ef189015..911e082144ef00f82fbe8adc5ffdc46c4191873a 100644 (file)
@@ -1551,10 +1551,11 @@ public final class EmacsWindow extends EmacsHandleObject
   {
     int[] array;
 
-    /* This is supposed to translate coordinates to the root
-       window.  */
+    /* This is supposed to translate coordinates to the root window,
+       whose origin point, in this context, is that of the toplevel
+       activity host to this view.  */
     array = new int[2];
-    EmacsService.SERVICE.getLocationOnScreen (view, array);
+    EmacsService.SERVICE.getLocationInWindow (view, array);
 
     /* Now, the coordinates of the view should be in array.  Offset X
        and Y by them.  */